//
//  GuideMallCell.m
//  MobileShoppingMall
//
//  Created by 冯传昌 on 2021/4/15.
//  Copyright © 2021 冯传昌. All rights reserved.
//

#import "GuideMallCell.h"

#import "WTKStarView.h"

@interface GuideMallCell()

///bgview
@property (nonatomic,strong) UIView *bgView;
///店铺logo图片
@property (nonatomic,strong) UIImageView *storeLogoImgV;
///店铺名lb
@property (nonatomic,strong) UILabel *storeNameLB;
///店铺位置信息
@property (nonatomic,strong) UILabel *storeAddressLB;
///店铺推荐原因
@property (nonatomic,strong) UILabel *recommendReasonLB;
///星级评分view
@property (nonatomic,strong) WTKStarView *starView;


@property (nonatomic,strong) UILabel *leftLB;

@end

@implementation GuideMallCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = MainBackColor;
        self.contentView.backgroundColor = MainBackColor;
        
        [self initUI];
    }
    return self;
}
#pragma mark - setter
- (void)setModel:(GuideMallModel *)model{
    _model = model;
    [self.storeLogoImgV sd_setImageWithURL:[NSURL URLWithString:_model.logo]];
    self.storeNameLB.text = _model.name;
    self.starView.star = _model.rate;
    self.storeAddressLB.text = [[_model.region stringByAppendingString:@" "] stringByAppendingString:_model.distance];
    self.recommendReasonLB.text = _model.reason;
//    self.recommendReasonLB.height = [Configuration getLabelHeightWithText:self.recommendReasonLB.text withFont:self.recommendReasonLB.font withLBWidth:self.recommendReasonLB.width];
//    self.bgView.height = self.recommendReasonLB.bottom + 10;
}

#pragma mark - UI
-(void)initUI{
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.storeLogoImgV];
    [self.bgView addSubview:self.storeNameLB];
    [self.bgView addSubview:self.starView];
    [self.bgView addSubview:self.storeAddressLB];
    [self.bgView addSubview:self.leftLB];
    [self.bgView addSubview:self.recommendReasonLB];
}

#pragma mark - lazy
-(UIView *)bgView{
    if (!_bgView) {
        _bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, ScreenWidth-30, 140)];
        _bgView.backgroundColor = UIColor.whiteColor;
        _bgView.clipsToBounds = YES;
        _bgView.layer.cornerRadius = 10;
    }
    return _bgView;
}
///店铺logo
-(UIImageView *)storeLogoImgV{
    if (!_storeLogoImgV) {
        _storeLogoImgV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 13, 86, 86)];
        _storeLogoImgV.image = LoadImage(@"指南商城_推荐店铺");
    }
    return _storeLogoImgV;
}
///店铺名称LB
-(UILabel *)storeNameLB{
    if (!_storeNameLB) {
        _storeNameLB = [[UILabel alloc] initWithFrame:CGRectMake(self.storeLogoImgV.right+10, self.storeLogoImgV.top, self.bgView.width-self.storeLogoImgV.width - 30, 24)];
        _storeNameLB.textColor = MainBlackTextColor;
        _storeNameLB.font = FontSet(17);
    }
    return _storeNameLB;
}
///星级评分
-(WTKStarView *)starView{
    if (!_starView) {
        _starView = [[WTKStarView alloc] initWithFrame:CGRectMake(self.storeNameLB.left, self.storeNameLB.bottom+6, 60, 13) starSize:CGSizeZero withStyle:WTKStarTypeFloat];
        _starView.isTouch = NO;
    }
    return _starView;
}
///店铺地址信息LB
-(UILabel *)storeAddressLB{
    if (!_storeAddressLB) {
        _storeAddressLB = [[UILabel alloc] initWithFrame:CGRectMake(self.storeLogoImgV.right+10, self.storeLogoImgV.bottom-36, self.bgView.width-self.storeLogoImgV.width - 30, 32)];
        _storeAddressLB.textColor = MainGrayTextColor;
        _storeAddressLB.font = FontSet(13);
        _storeAddressLB.numberOfLines = 2;
    }
    return _storeAddressLB;
}
///leftLB
-(UILabel *)leftLB{
    if (!_leftLB) {
        _leftLB = [[UILabel alloc] initWithFrame:CGRectMake(self.storeLogoImgV.left, self.storeLogoImgV.bottom+10, self.storeLogoImgV.width, 20)];
        _leftLB.textColor = MainBlackTextColor;
        _leftLB.font = FontSetWithWeight(14, 0.3f);
        _leftLB.text = @"推荐理由:";
    }
    return _leftLB;
}
///推荐理由
-(UILabel *)recommendReasonLB{
    if (!_recommendReasonLB) {
        _recommendReasonLB = [[UILabel alloc] initWithFrame:CGRectMake(self.leftLB.right, self.leftLB.top, self.bgView.width-self.storeLogoImgV.width - 20, 20)];
        _recommendReasonLB.textColor = MainGrayTextColor;
        _recommendReasonLB.font = FontSet(13);
    }
    return _recommendReasonLB;
}



@end
